package com.zl_huang.example.dao;

import java.util.List;

import org.hibernate.Session;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.zl_huang.example.model.UserRole;
@Repository
public class UserRoleDaoImpl extends BaseHibernateDAO<UserRole> implements IUserRoleDaoHibernate {

	@Override
	@Transactional
	public UserRole getUserRoleById(String user_id) throws Exception {
		Session session = getSession();
		String hql = "from UserRole where user_id = "+user_id;
		@SuppressWarnings("unchecked")
		List<UserRole> list = session.createQuery(hql).list();	
		return list.get(0);
	}

	@Override
	@Transactional
	public UserRole getUserRoleById(Integer role_id) throws Exception {
		Session session = getSession();
		String hql = "from UserRole where role_id = "+role_id;
		@SuppressWarnings("unchecked")
		List<UserRole> list = session.createQuery(hql).list();	
		return list.get(0);
	}

}
